<script>
$(function(){
    $('img[class=modi]').click(function(event){
        $('#cart_pid').val($(this).attr('rel'));
        // 取消事件冒泡
        event.stopPropagation();

        var offset = $(event.target).offset();
        $("#cart_confirm").css({ top: offset.top + $(event.target).height() + "px", left: offset.left-80 });
        $('#cart_confirm').show();
    });
    $('img[class=del]').click(function(){
        $.post(location.href,{type:'del',pid:$(this).attr('rel')},function(){
            window.location.reload();
        },'json');
    });
    $('#close_cart').click(function(){
        $('#cart_confirm').hide();
    });
    $('#submit_cart').click(function(){
        $.post(location.href,{type:'modi',pid:$('#cart_pid').val(),num:$('#cart_pnum').val(),price:$('#price').val()},function(data){
            if (data.state <= 0)
            {
                alert(data.message);
                return false;
            }
            window.location.reload();
        },'json');
    });
});
</script>
<div class="line_1"></div>
<table width="100%" cellpadding="0" cellspacing="0" border="0" class="table1">
       <tr>
            <th class="th0">编号</th>
            <th class="th1">商品民称</th>
            <th class="th0">库存</th>
            <th class="th0">已售出</th>
            <th class="th0">购买数量</th>
            <th class="th0">实售价</th>
            <th class="th0">实售小计</th>
            <th class="th0">操作</a>
       </tr>
       <?php foreach((array)$this->products as $product): ?> 
       <tr>
            <td><?php echo $product['product_id']; ?></td>
            <td><?php echo $product['name']; ?></td>
            <td><?php echo $product['num']; ?></td>
            <td><?php echo $product['sold_num']; ?></td>
            <td><?php echo $this->cartinfo[$product['product_id']][0] ?></td>
            <td><?php echo $this->cartinfo[$product['product_id']][1]; ?></td>
            <td><?php echo $product['pra_price']; ?></td>
            <td><?php echo opt('edit','javascript:;',"title='更改数量' class='modi' rel='{$product['product_id']}'").opt('trash','javascript:;',"title='从购物车中删除' class='del' rel='{$product['product_id']}'"); ?></td>
       </tr>
       <?php endforeach; ?>
</table>
<div class="page_num">
     <div class="fl">
        <span>总价小计&nbsp;<strong>实际售价小计：</strong><?php echo $this->total_pra_price; ?></span>
     </div>
     <div class="fr">
        <p class="cpager">
            <a href="?app=order&mod=systemsubmit&uid=<?php echo $_GET['uid']; ?>&step=3" id="">确认无误，下一步，选择收货地址 &gt;</a>
        </p>
     </div>
</div>
<div id='cart_confirm' style="display:none;background:skyblue;padding:5px;font-weight:bold;font-family:'黑体';font-size:14px;position:fixed;">
    数量：<input style="width:40px;height:14px;" id="cart_pnum" value="1" /><br/>单价：<input style="width:40px;height:14px;" id="price" value="0.00" /><br/><input type="submit" class="btn1" id="submit_cart" value="确定" /><input type="button" value="关闭" id='close_cart'/><input type="hidden" id="cart_pid" value=''/>
</div>